package com.lanier.dydownloader

import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.junit.Assert.*
import org.junit.Test
import us.codecraft.xsoup.Xsoup

class TestDouyin {

    @Test
    fun testSelect() {
        val html = """
            <html>
            
            <div><a href='https://github.com'>github.com</a></div>
             <table><tr><td>a</td><td>b</td></tr></table>
                
           </html>
        """.trimIndent()
        val document: Document = Jsoup.parse(html)
        val result = Xsoup.compile("//a/@href").evaluate(document).get()
        assertEquals("https://github.com", result)
        println("信息: result:$result")

        val list = Xsoup.compile("//tr/td/text()").evaluate(document).list()
        println("信息: list:[${list.map { "$it," }}]")
        assertEquals("a", list[0])
        assertEquals("b", list[1])

    }

    @Test
    fun testSelectDouYin() {
//        println("信息: key:${DouYin.getTtwid()}")
//
//        val key = DouYin.getKey("https://v.douyin.com/idoG6UTD/")
//        println("信息: key:$key")




    }

}